package com.sc.nft.service.impl;

import com.sc.nft.dao.MallOrderRefundStatusLogDao;
import com.sc.nft.entity.MallOrderRefundStatusLog;
import com.sc.nft.enums.MallRefundStatusEnum;
import com.sc.nft.service.MallOrderRefundStatusLogService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 售后单操作日志实现层
 *
 * @author liGen
 * @version 1.0
 * @date 2023/11/23 2:10 下午
 */
@Slf4j
@RequiredArgsConstructor
@Service
public class MallOrderRefundStatusLogServiceImpl implements MallOrderRefundStatusLogService {

    private final MallOrderRefundStatusLogDao mallOrderRefundStatusLogDao;

    /**
     * 根据售后单id查询售后单操作日志
     *
     * @param orderRefundId
     * @return
     */
    @Override
    public List<MallOrderRefundStatusLog> getListByOrderRefundId(Long orderRefundId) {
        return mallOrderRefundStatusLogDao.getListByOrderRefundId(orderRefundId);
    }

    @Override
    public MallOrderRefundStatusLog getByOrderIdAndChangeType(Long orderRefundId, String changeType) {
        return mallOrderRefundStatusLogDao.getByOrderIdAndChangeType(orderRefundId,changeType);
    }

    /**
     * 创建售后单操作日志
     *
     * @param orderRefundId
     * @param mallRefundStatusEnum
     * @param changeMessage
     */
    @Override
    public void create(Long orderRefundId, MallRefundStatusEnum mallRefundStatusEnum, String changeMessage) {
        MallOrderRefundStatusLog mallOrderRefundStatusLog = new MallOrderRefundStatusLog();
        mallOrderRefundStatusLog.setOrderRefundId(orderRefundId);
        mallOrderRefundStatusLog.setChangeType(mallRefundStatusEnum.toString());
        mallOrderRefundStatusLog.setChangeMessage(changeMessage);
        mallOrderRefundStatusLog.insert();
    }
}
